<?php
$this->layout='//layouts/column1';
$this->breadcrumbs=array(
	'Customers',
);

$this->menu=array(
	array('label'=>'Create Customer', 'url'=>array('create')),
);
/* 
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('customer-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
*/
?>

<h1>Manage Customers</h1>
<p>
<?php 
	if(!User::getCurrentUser()->isReception())
		echo CHtml::link("Create Customer",array('create'));
	
?></p>

<?php /* 
<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
echo CHtml::link('Advanced Search','#',array('class'=>'search-button'));
<div class="search-form" style="display:none">
$this->renderPartial('_search',array(
	'model'=>$model,
)); 
</div><!-- search-form -->
*/?>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'customer-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
/*		'fileReferenceNo',
		array(
			'name'=>'title',
			'filter'=>'',
		),
		array(
			'name'=>'dateOfBirth',
			'filter'=>'',
		),
		array(
			'name'=>'createUserId',
			'type'=>'raw',
			'filter'=>CHtml::listData(User::model()->findAll(), 'id', 'fullName'),
			'value'=>'$data->createUser->fullName',
		),
		'email',
		'physicalAddress',
		'physicalSuburb',
		'physicalPostcode',
		array(
			'name'=>'physicalState',
			'filter'=>DataUtil::getStates(),
		),
		'postalCountry',		
		'physicalCountry',
		'BankName',
		'valueStar',
		'BankAccountNumber',
		
		array(
			'header'=>'Attachments',
			'type'=>'raw',
			'value'=>'CHtml::link($data->attachmentCount,array("attachment/admin","customerId"=>$data->id))',
		),
*/	
		'firstName',
		'lastName',
		'otherName',
		array(
			'name'=>'gender',
			'filter'=>DataUtil::getGenders(),
			'value'=>'$data->gender?"Male":"Female"',
		),
		'consultant',
		'companyName',
		'contactPhone',
		'contactMobile',
		'postalAddress',
		'postalSuburb',
		'postalPostcode',
		array(
			'name'=>'postalState',
			'filter'=>DataUtil::getStates(),
		),
		array(
			'name'=>'teamId',
			'type'=>'raw',
			'filter'=>Yii::app()->user->checkAccess('manager') || User::getCurrentUser()->isReception() ? CHtml::listData(Team::model()->findAll(array('condition'=>'id != 100')), 'id', 'name'):'',
			'value'=>'empty($data->team)?"":$data->team->name',
		),
		array(
			'visible'=>!User::getCurrentUser()->isReception(),
			'class'=>'CButtonColumn',
			//'template'=>'{view} {update}',
			'deleteConfirmation'=>'Deleting a Customer will PERMANENTLY delete all relevant records! Are you sure to continue?'
		),
	),
)); ?>
